home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 644 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  3.2 KB

  1. Path: chronicle.mti.sgi.com!austern
  2. From: James Kanze US/ESC 60/3/141 #40763 <kanze@lts.sel.alcatel.de>
  3. Newsgroups: comp.std.c++
  4. Subject: Re: constant-expression extension
  5. Date: 06 Mar 1996 09:43:18 PST
  6. Organization: -
  7. Approved: austern@isolde.mti.sgi.com
  8. Message-ID: <9603061619.AA10444@lts.sel.alcatel.de>
  9. References: <4h775a$m4s@ugress.uib.no> <KANZE.96Mar4120725@gabi.gabi-soft.fr> <4hh34b$21r@ugress.uib.no>
  10. NNTP-Posting-Host: isolde.mti.sgi.com
  11. X-Original-Date: Wed, 6 Mar 96 17:19:38 +0100
  12. In-Reply-To: boukanov@kvark.fi.uib.no's message of 05 Mar 1996 09:44:14 PST
  13. X-Auth: PGPMoose V1.1 PGP comp.std.c++
  14.     iQBVAwUBMT3OzEy4NqrwXLNJAQGwpgH/TYx1AwN2trtDktdsVqXbfb5Smm10QHJu
  15.     vC+yjSIJpCDnqjy0Hn3iVuGo0eYerx5f6Hf/es4JYMl22TbZ+sEFEg==
  16.     =Knaj
  17. Originator: austern@isolde.mti.sgi.com
  18.  
  19. In article <4hh34b$21r@ugress.uib.no> boukanov@kvark.fi.uib.no (Igor
  20. Boukanov) writes:
  21.  
  22. |> J. Kanze (kanze@gabi-soft.fr) wrote:
  23. |> > That it would be nice, but that there are two very big problems:
  24.  
  25. |> > 1. It would basically require a complete C++ interpreter in the
  26. |> > compiler, and
  27.  
  28. |> But in almost all cases such interpreter is already present in C++ 
  29. |> compilers! Because of cause all such const look expressions are correct 
  30. |> C++ expressions so every C++ compiler has to generate a code that will 
  31. |> evaluate them at run time and if forget about the crosscompilation case 
  32. |> I think instead of putting the code to object file compiler can just execute 
  33. |> it...
  34.  
  35. Generating code and interpreting it are two different things.  For
  36. example, the code generator only knows about the current scope (stack
  37. frame); the compiler typically has no mechanism for maintaining the
  38. image of multiple stack frames (needed is it is to evaluate a
  39. function) internall.
  40.  
  41. |> > 2. It would make the notion of constant expression somewhat
  42. |> > implementation dependant.  Suppose my compiler implements the function
  43. |> > sin as an inline invocation of a compiler built-in.  Can I then use sin
  44. |> > in a constant expression?
  45.  
  46. |> Consider, for example, next:
  47. |> const double x = 1.0 / (very small number); 
  48. |> And of cause, the result will depend on exact representation of double... 
  49.  
  50. Agreed.  That is why the above is not a constant expression, according
  51. to the draft standard.  Think about the case of a cross-compiler: it
  52. would be very unintuitive if `1.0 / (very small number)' gave
  53. different results than assigning 1.0 to a double variable, then
  54. dividing the double variable by `(a very small number)'.  A
  55. (cross-)compiler is not required to emulate the floating point
  56. arithmetic of the target machine.
  57.  
  58. --
  59. James Kanze         Tel.: (+33) 88 14 49 00        email: kanze@gabi-soft.fr
  60. GABI Software, Sarl., 8 rue des Francs-Bourgeois, F-67000 Strasbourg, France
  61. Conseils, itudes et rialisations en logiciel orienti objet --
  62.                 -- A la recherche d'une activiti dans une region francophone
  63. ---
  64. [ comp.std.c++ is moderated.  To submit articles: Try just posting with your 
  65.                 newsreader.  If that fails, use mailto:std-c++@ncar.ucar.edu
  66.   comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
  67.   Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
  68.   Comments? mailto:std-c++-request@ncar.ucar.edu 
  69. ]
  70.